function payWX() {
    var appId = "";
    var timeStamp = "";
    var nonceStr = "";
    var package = "";
    var signType = "";
    var paySign = "";

    function onBridgeReady() {
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest', {
                "appId": appId,     //公众号名称，由商户传入     
                "timeStamp": timeStamp,         //时间戳，自1970年以来的秒数     
                "nonceStr": nonceStr, //随机串     
                "package": package,
                "signType": signType,         //微信签名方式：     
                "paySign": paySign //微信签名 
            },
            function (res) {
                if (res.err_msg == "get_brand_wcpay_request:ok") {
                    // console.log("ok");
                } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
                    // console.log("fail");
                } else {
                    // console.log("fail");
                }     // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。 


                var api = axios.create({
                    baseURL: 'https://api.tl100.com/exam_signup',
                    withCredentials: true,
                    timeout: 5000
                });
                var params = {};
                // params.order_id = "4F807EB00BD911E8A7DD6556B004217E";
                params.token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxOTc5NSwiZXhwIjoxNTIwNDA1NjE0MzExLCJyb2xlX2lkIjowfQ.Kbb9u1FD3gCA_07N9RFVCFQWvDOpIzNtbcrzMnX5pOc";
                api.post('/api/sign_up/getWxOrder', params)
                    .then(function (response) {
                        var rs_data = response.data.msg;
                        if (rs_data.state == 1) {
                            console.log("ok");
                        } else {
                            console.log("fail");
                        }
                    })
                    .catch(function (error) {
                        console.log("fail");
                    });
            }
        );
    }

    var api = axios.create({
        baseURL: 'https://api.tl100.com/exam_signup',
        withCredentials: true,
        timeout: 5000
    });
    var params = {};
    params.order_id = "4F807EB00BD911E8A7DD6556B004217E";
    params.sign_up_id = 1;
    params.token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxOTc5NSwiZXhwIjoxNTIwNDA1NjE0MzExLCJyb2xlX2lkIjowfQ.Kbb9u1FD3gCA_07N9RFVCFQWvDOpIzNtbcrzMnX5pOc";
    params.code = document.getElementsByClassName("code")[0].innerText;
    api.post('/api/sign_up/wxPay', params)
        .then(function (response) {
            var rs_data = response.data.msg;

            appId = rs_data.appId;
            timeStamp = rs_data.timeStamp;
            nonceStr = rs_data.nonceStr;
            package = rs_data.package;
            signType = rs_data.signType;
            paySign = rs_data.paySign;

            if (typeof WeixinJSBridge == "undefined") {
                if (document.addEventListener) {
                    document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
                } else if (document.attachEvent) {
                    document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                    document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
                }
            } else {
                onBridgeReady();
            }
        })
        .catch(function (error) {
            console.log("fail");
        });
}

function payQQ() {
    var api = axios.create({
        baseURL: 'https://api.tl100.com/exam_signup',
        withCredentials: true,
        timeout: 5000
    });
    var params = {};
    // params.order_id = "4F807EB00BD911E8A7DD6556B004217E";
    // params.sign_up_id = 1;
    params.token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxOTc5NSwiZXhwIjoxNTIwNDA1NjE0MzExLCJyb2xlX2lkIjowfQ.Kbb9u1FD3gCA_07N9RFVCFQWvDOpIzNtbcrzMnX5pOc";
    // params.code = document.getElementsByClassName("code")[0].innerText;
    api.post('/api/sign_up/qqPay', params)
        .then(function (response) {
            var rs_data = response.data.msg;
            mqq.tenpay.pay({
                tokenId: rs_data.tokenId,
                // pubAcc: "xxxx",
                // pubAccHint: "xxxx",
                // appInfo: "appid#XXXXXXXXX|bargainor_id#XXXXXXXX|channel#wallet"
            }, function (result, resultCode) {
                if (result.resultCode == 0) {
                    console.log("ok");
                    console.log(result.data);
                } else {
                    console.log("fail");
                    console.log(result);
                }
            });
        })
        .catch(function (error) {
            console.log("fail");
            console.log(error);
        });
}


function payAli() {
    var api = axios.create({
        baseURL: 'https://api.tl100.com/exam_signup',
        withCredentials: true,
        timeout: 5000
    });
    var params = {};
    params.token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxOTc5NSwiZXhwIjoxNTIwNDA1NjE0MzExLCJyb2xlX2lkIjowfQ.Kbb9u1FD3gCA_07N9RFVCFQWvDOpIzNtbcrzMnX5pOc";
    api.post('/api/sign_up/aliPay', params)
        .then(function (response) {
            var rs_data = response.data.msg;
            location.href = "https://openapi.alipay.com/gateway.do?" + rs_data;
            // var api2 = axios.create({
            //     baseURL: 'https://openapi.alipay.com',
            //     withCredentials: true,
            //     timeout: 5000
            // });
            // var params2 = rs_data;
            // api2.get('/gateway.do?'+params2).then(function (response) {
            //     console.log(response)
            // }).catch(function (error) {
            //     console.log("fail");
            // });
        })
        .catch(function (error) {
            console.log("fail");
        });
}


